import React from 'react'
import { Table } from 'antd'
import PropTypes from 'prop-types'
import CatViewer from './CatViewer'

class IcsComponentsIdleGrid extends React.Component {
    state = {
        isEditing: false,
        showCatViewer: false
    }
    componentDidMount () {
    }
    edit = (val) => {
        this.setState({rowInfo: val, isEditing: true, showCatViewer: true})
    }
    doViewer = () => {
        this.setState({showCatViewer: false})
    }

    render () {
        return (
            <div className="manager-grid">
                <Table
                    pagination={false}
                    dataSource={this.props.list}
                    rowKey="id">
                    <Table.Column
                        title="品类ID"
                        width={120}
                        dataIndex="id"
                    />
                    <Table.Column
                        title="品类名称"
                        dataIndex="cat_name"
                        width={150}
                    />
                    <Table.Column
                        title="归属商场"
                        width={120}
                        dataIndex="store_type"
                        render={(text, row) => {
                            return '商城一'
                        }}
                    />
                    <Table.Column
                        title="上级品类"
                        width={150}
                        dataIndex="parent_name"
                    />
                    <Table.Column
                        title="商品数量"
                        width={120}
                        dataIndex="xx"
                    />
                    <Table.Column
                        title="操作"
                        width={120}
                        dataIndex="ff"
                        render={(text, row) => {
                            return <a onClick={() => this.edit(row)}>编辑</a>
                        }}
                    />
                </Table>
                <CatViewer allClassifyList={this.props.allClassifyList} doSearch={this.props.doSearch} showCatViewer={this.state.showCatViewer} isEditing={this.state.isEditing} doViewer={this.doViewer} rowInfo={this.state.rowInfo}></CatViewer>
            </div>
        )
    }
}

IcsComponentsIdleGrid.propTypes = {
    onCreate: PropTypes.func,
    onIdleDetail: PropTypes.func,
    grid: PropTypes.any,
    doSearch: PropTypes.func,
    allClassifyList: PropTypes.array,
    list: PropTypes.array
}
export default IcsComponentsIdleGrid
